home *** CD-ROM | disk | FTP | other *** search
- #ifndef SCANLIB_H
- #define SCANLIB_H
-
- /*
- ** $Filename: add-ons/developer/syntax/scanlib.h
- ** $Release: 6.2.3
- **
- ** Syntax parser definitions.
- **
- ** (C) Copyright 1999 Dietmar Eilert
- ** All Rights Reserved
- */
-
- #ifndef MAKE_ID
- #define MAKE_ID(a,b,c,d) ((ULONG) (a)<<24 | (ULONG) (b)<<16 | (ULONG) (c)<<8 | (ULONG) (d))
- #endif
-
- #define PARSER_MAGIC MAKE_ID('G','E','D','6')
-
- /* library base */
-
- struct ParserBase {
-
- struct Library Library; /* standard library */
- UWORD pad; /* we are now longword aligned */
- ULONG Magic; /* checked by editor to recognize syntax parsers */
- };
-
- /* general description of parser properties (created by parser) */
-
- struct ParserData {
-
- ULONG pd_Release; /* version code of syntax parser interface */
- ULONG pd_Version; /* private release code of parser (optional) */
- ULONG pd_Serial; /* private serial code of parser (optional) */
- UBYTE *pd_Info; /* short description */
- UBYTE **pd_Example; /* example text array or NULL */
- UWORD pd_Flags; /* flags (see below) */
- ULONG pd_Properties; /* configurability flags for generic configuration interface (see below) */
- APTR pd_Reserved; /* reserved */
-
- /* private data of syntax parser may follow */
- };
-
- /* syntax parsing interface version supported by parser (ParserData->pd_Release) */
-
- #define SCANLIBVERSION 6
-
- /* flags (ParserData->pd_Flags) */
-
- #define SCPRB_CONFIGWIN 1L /* syntax parser has its own configuration window */
- #define SCPRF_CONFIGWIN (1L<<1)
-
- #define SCPRB_SYNTAXCACHE 2L /* syntax cache supported */
- #define SCPRF_SYNTAXCACHE (1L<<2)
-
- #define SCPRB_CONTEXT 3L /* context parsing supported */
- #define SCPRF_CONTEXT (1L<<3)
-
- #define SCPRB_GENERIC 4L /* generic configuration interface supported */
- #define SCPRF_GENERIC (1L<<4)
-
- /* configurable properties (ParserData->pd_Properties) */
-
- #define SCPRB_DICTIONARY 1L /* parser supports dictionary */
- #define SCPRF_DICTIONARY (1L<<1)
-
- #define SCPRB_CASESENSITIVITY 2L /* parser supports case-sensitivity */
- #define SCPRF_CASESENSITIVITY (1L<<2)
-
- #define SCPRB_COMMENTS 3L /* parser supports comments (normal comments) */
- #define SCPRF_COMMENTS (1L<<3)
-
- #define SCPRB_COMMENTLINES 4L /* parser supports comments (comments until end of line) */
- #define SCPRF_COMMENTLINES (1L<<4)
-
- #define SCPRB_COMMENTNESTING 5L /* parser supports nested comments */
- #define SCPRF_COMMENTNESTING (1L<<5)
-
- #define SCPRB_STRINGS 6L /* parser supports strings */
- #define SCPRF_STRINGS (1L<<6)
-
- #define SCPRB_STRINGESC 7L /* parser supports string esc sequence */
- #define SCPRF_STRINGESC (1L<<7)
-
- #define SCPRB_LITERALS 8L /* parser supports literals */
- #define SCPRF_LITERALS (1L<<8)
-
- #define SCPRB_LITERALESC 9L /* parser supports literal esc sequence */
- #define SCPRF_LITERALESC (1L<<9)
-
- #define SCPRB_BLOCKS 10L /* parser supports blocks */
- #define SCPRF_BLOCKS (1L<<10)
-
- #define SCPRB_BLOCKNESTING 11L /* parser supports nested blocks */
- #define SCPRF_BLOCKNESTING (1L<<11)
-
- #define SCPRB_PREFIXBIN 12L /* parser supports bin prefix */
- #define SCPRF_PREFIXBIN (1L<<12)
-
- #define SCPRB_PREFIXOCT 13L /* parser supports oct prefix */
- #define SCPRF_PREFIXOCT (1L<<13)
-
- #define SCPRB_PREFIXHEX 14L /* parser supports hex prefix */
- #define SCPRF_PREFIXHEX (1L<<14)
-
- #define SCPRB_WHITESPACE 15L /* parser supports whitespace definition */
- #define SCPRF_WHITESPACE (1L<<15)
-
- #define SCPRB_COMMENTALT 16L /* parser supports alternative comment */
- #define SCPRF_COMMENTALT (1L<<16)
-
- /* parser handle (created by parser) */
-
- struct ParserHandle {
-
- UWORD ph_Levels; /* number of syntax levels understood by parser */
- UBYTE **ph_Names; /* array of level names (0-terminated) */
- ULONG *ph_ColorsFG; /* suggested colors (BGR, see below) */
- ULONG *ph_ColorsBG; /* suggested colors (BGR, see below) */
- APTR ph_Reserved; /* reserved */
-
- /* private data of syntax parser may follow */
- };
-
- /* data format of color table 00bbggrr (ParserHandle->ph_ColorsFG/BG) */
-
- #define MAKE_BGR8(b,g,r) ((ULONG)(((ULONG)b) & 255)<<16 | (ULONG)(((ULONG)g) & 255)<<8 | (ULONG)((ULONG)(r) & 255))
-
- /* syntax chunk (the parser returns an 0-terminated array of this structure to the editor) */
-
- struct SyntaxChunk {
-
- UWORD sc_Start; /* column: segment start */
- UWORD sc_End; /* column: segment end */
- UWORD sc_Level; /* syntax level of this segment */
- };
-
- /* syntax parser notification message (sent from editor to syntax parser) */
-
- struct ScannerNotify {
-
- ULONG sn_Class; /* action class */
- ULONG sn_Code; /* action code */
- ULONG sn_Line; /* line of operation */
- LONG sn_Lines; /* lines affected by operation */
- LONG sn_Removed; /* lines removed during operation */
- APTR sn_Reserved; /* reserved (set to NULL) */
- };
-
- /* notification classes (ScannerNotify->sn_Class) */
-
- #define SCANNER_NOTIFY_MODIFIED 1L /* lines have been inserted, deleted or modified */
-
- /* display refresh request (created by syntax parser to request an additional display refresh) ) */
-
- struct RefreshRequest {
-
- ULONG rr_Line; /* first line to be refreshed */
- ULONG rr_Lines; /* lines to be refreshed */
- };
-
- /* setup information (created by editor) */
-
- struct SyntaxSetup {
-
- struct List *sp_Categories; /* dictionary categories (or NULL) */
- struct Entry *sp_Dictionary; /* dictionary, sorted and 0-terminated (or NULL) */
- BOOL sp_CaseSensitive; /* case-sensitive dictionary ? */
- UBYTE *sp_CommentStart; /* comment delimiter (or NULL) */
- UBYTE *sp_CommentEnd; /* comment delimiter (or NULL) */
- UBYTE *sp_CommentLine; /* comment delimiter (or NULL) */
- BOOL sp_CommentNesting; /* comment nesting ? */
- UBYTE *sp_BlockStart; /* block delimiter (or NULL) */
- UBYTE *sp_BlockEnd; /* block delimiter (or NULL) */
- BOOL sp_BlockNesting; /* block nesting ? */
- BOOL sp_WhiteSpace[256]; /* white-space definition array */
- UBYTE *sp_PrefixBin; /* number prefix (or NULL) */
- UBYTE *sp_PrefixOct; /* number prefix (or NULL) */
- UBYTE *sp_PrefixHex; /* number prefix (or NULL) */
- UBYTE *sp_String; /* string delimiter (or NULL) */
- UBYTE *sp_StringESC; /* string escape sequence (or NULL) */
- UBYTE *sp_Literal; /* literal delimiter (or NULL) */
- UBYTE *sp_LiteralESC; /* literal escape sequence (or NULL) */
- UBYTE *sp_Arguments; /* other arguments (or NULL) */
- UBYTE *sp_CommentAlt; /* alternative comment delimiter (or NULL) */
- };
-
- /* dictionary entry; this is a VARIABLE-SIZED STRUCTURE (word-aligned via pad-bytes) ! */
-
- struct Entry {
-
- UWORD en_Length; /* keyword length */
- UWORD en_Category; /* keyword category (ID in bit 0-7) */
- UBYTE en_Text[1]; /* 0-terminated string follows */
- };
-
- /* minimum size of the previous structure */
-
- #define SIZEOF_STRUCT_ENTRY (sizeof(UWORD) + sizeof(UWORD))
-
- #endif
-